package org.hry.netty.filter;

import io.netty.handler.ipfilter.IpFilterRule;
import io.netty.handler.ipfilter.IpFilterRuleType;

import java.net.InetSocketAddress;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2021/11/27
 **/
public class IpFilterRuleHandler implements IpFilterRule {
    /**
     * 如果是TRUE的话 就需要执行 自定义的规则类型
     *
     * @param remoteAddress InetSocketAddress
     * @return 结果
     */
    @Override
    public boolean matches(InetSocketAddress remoteAddress) {
        System.out.println(remoteAddress.getAddress().getHostAddress());
        System.out.println(remoteAddress.getHostName());
        System.out.println(remoteAddress.getHostString());
        System.out.println(remoteAddress.getPort());
        return true;
    }

    @Override
    public IpFilterRuleType ruleType() {
        return IpFilterRuleType.REJECT;
    }
}
